// 列表的下拉更多
function dropdown() {
    $(".dropdown").on({
        mouseenter: function () {
            var top = $(this).offset().top - $(window).scrollTop()
            var left = $(this).offset().left + $(this).width()
            $(this).find("ul").css({ "left": left + 'px', 'top': top + 'px' });
            $(this).find("ul").stop().slideDown(300);
        },
        mouseleave: function () {
            $(this).find("ul").stop().slideUp(10);
        },
        mousewheel: function () {
            $(this).find("ul").stop().slideUp(10);
        }
    })
}
dropdown()
// 属性hover提示
var layerdatatips
$(".matchwarp .layertips").on({
    mouseenter: function () {
        var tex = $(this).attr("data-tex");
        layerdatatips = layer.tips(tex, this, { tips: [2, '#666666'], time: 0, skin: 'layerdatatips' });
    },
    mouseleave: function () {
        layer.close(layerdatatips)
    }

})
// 攻略精品推荐
if ($(".newlatest .lunbox .bd li").size() > 1) {
    jQuery(".newlatest .lunbox").slide({
        mainCell: ".bd ul",
        autoPage: "true",
        effect: "left",
        vis: 5,
        startFun: function (i, c) {
            $(window).trigger('scroll');
        }
    })
}
// 今天看了什么的js
function Date_doday() {
    let that = this;
    that.defaultIndex = 0;
    that.isFirstRunSetTitle = true;
    that.slide_ = '';
    that.getday_ = (day) => {
        let now_ = new Date(day);
        let w = now_.getDay();
        var w1 = ['日', '一', '二', '三', '四', '五', '六'];
        return w1[w];
    };
    that.index_=function(obj){
        $(obj).addClass("now").siblings().removeClass('now');
        that.defaultIndex = $(obj).index() - 3;
        if ($(obj).index() >= $(".matchToday .matchDatebox .slide .bd li").size() - 6 && that.defaultIndex > 7) {
            that.defaultIndex = $(".matchToday .matchDatebox .slide .bd li").size() - 7
        }
        if (that.defaultIndex <= 0) {
            that.defaultIndex = 0
        }
               
    };
    that.matchdata = function () {
        // let now = new Date('Mon Jan 11 2023 11:16:39 GMT+0800 (中国标准时间)');
        let now = new Date();
        let nowStr = now.getFullYear() + "-"
            + (now.getMonth() + 1 < 10 ? "0" + (now.getMonth() + 1) : now.getMonth() + 1) + "-"
            + (now.getDate() < 10 ? "0" + now.getDate() : now.getDate()) + "";
        $(".matchToday .matchDatebox .slide .bd li").each(function () {
            var time = $(this).find("a").attr("data-time");
            $(this).find("a span").text(time.substr(5, 5))
            $(this).find("a p").text("星期" + that.getday_(time));
            if (time === nowStr) {
                var text = $(this).find("a p").text();
                $(this).find("a p").text(text + "(今天)");
                that.index_(this)
            }
            if($(".matchToday .matchDatebox .slide .bd li.active").size()>0){
                that.index_('.matchToday .matchDatebox .slide .bd li.active')
            }

        })
    };
   

    that.matchdata();
    // 今天看了什么的日期调用  
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#matchDate' //指定元素
            , showBottom: false
            , done: function (value, date, endDate) {
                // 这里是点击日历的选项
                console.log(value)
                that.slide_[0].destroy();
                $(".matchToday .matchDatebox .slide .bd li").each(function () {
                    var time = $(this).find("a").attr("data-time");
                    if (time === value) {
                        that.defaultIndex = $(this).index() - 3;
                        $(this).addClass("now").siblings().removeClass('now');
                    }
                })
                that.slide();
            }
        });
    });
    that.slide = function () {
        if ($(".matchToday .matchDatebox .slide .bd li").size() > 1) {
            that.slide_ = $(".matchToday .matchDatebox .slide").slide({
                mainCell: ".bd ul",
                autoPage: "true",
                effect: "leftLoop",
                vis: 7,
                scroll: 1,
                defaultIndex: that.defaultIndex,
                startFun: function (i, c) {
                }
            });
        }
    }
    that.slide();
}
var Date_doday = new Date_doday();//实例化对象
